window.onload=function (){

    let workHeadFormSelectObj=document.getElementById("workHeadFormSelect");
    if(workHeadFormSelectObj){
        workHeadFormSelectObj.onclick=function (event){
            if(!workHeadFormSelectObj.isNew){
                this.options.length=0;
                $.ajax({
                    type: "post",
                    // url: "<%=basepath%>userServlet?action=ajaxExistUsername",
                    url:"http://www.baidu.com",
                    // data: $('form').serialize(), //它可以把表单用name序列化成一个字符串
                    data:{},
                    success: function (response, status, xhr) {
                        //console.log(response)
                        var jsonObj = JSON.parse(response);
                        jsonObj={
                            "key0":"default",
                            "key1":"service",
                            "key2":"project",
                            "key3":"ip",
                        };
                        for (let i in jsonObj){
                            workHeadFormSelectObj.options.add(new Option(jsonObj[i],jsonObj[i]));
                        }
                        workHeadFormSelectObj.isNew=true;
                        //var jsonObj=$.parseJSON( response )
                        //console.log(typeof (jsonObj));
                        //console.log(jsonObj["existsUsername"]);//js中的json对象要这样读
                        // if (jsonObj["existsUsername"]) {
                        //     $(".errorMsg").text("用户名不可用")
                        // } else {
                        //     $(".errorMsg").text("用户名可用")
                        // }
                    },
                    timeout: 10000, //如果超时1000毫秒，就结束
                    error: function (xhr, errorText, errorType) { //错误后的行为

                        console.log("errorText:" + errorText); //error
                        console.log("errorType:" + errorType); //not found
                        console.log("xhr.status:" + xhr.status); //404
                        console.log("xhr.statusText:" + xhr.statusText); //not found
                    },
                    dataType: "text" //类型还有json,能免去接受到回复后,处理json文本后的过程 还有xml类型,一般不用
                })
            }
        }
    }

    let workHeadFileOutObj=document.getElementById("workHeadFormSelect");
    if (workHeadFileOutObj){
        workHeadFileOutObj.onclick=function (event){
            if(!workHeadFormSelectObj.isNew){
                this.options.length=0;
                $.ajax({
                    type: "post",
                    // url: "<%=basepath%>userServlet?action=ajaxExistUsername",
                    url:"http://www.baidu.com",
                    // data: $('form').serialize(), //它可以把表单用name序列化成一个字符串
                    data:{},
                    success: function (response, status, xhr) {
                        //console.log(response)
                        var jsonObj = JSON.parse(response);

                        //var jsonObj=$.parseJSON( response )
                        //console.log(typeof (jsonObj));
                        //console.log(jsonObj["existsUsername"]);//js中的json对象要这样读
                        // if (jsonObj["existsUsername"]) {
                        //     $(".errorMsg").text("用户名不可用")
                        // } else {
                        //     $(".errorMsg").text("用户名可用")
                        // }
                    },
                    timeout: 10000, //如果超时1000毫秒，就结束
                    error: function (xhr, errorText, errorType) { //错误后的行为

                        console.log("errorText:" + errorText); //error
                        console.log("errorType:" + errorType); //not found
                        console.log("xhr.status:" + xhr.status); //404
                        console.log("xhr.statusText:" + xhr.statusText); //not found
                    },
                    dataType: "text" //类型还有json,能免去接受到回复后,处理json文本后的过程 还有xml类型,一般不用
                })
            }
        }
    }
    let workMainTableTrObjList=document.getElementsByClassName("tr");
    for (let i=0 ;i< workMainTableTrObjList.length;i++){
        let oldColor=""
        workMainTableTrObjList[i].onmouseenter=function (){
            oldColor=this.style.backgroundColor;
            this.style.backgroundColor="#C0C0C0";
        }
        workMainTableTrObjList[i].onmouseout=function (){
            this.style.backgroundColor=oldColor;
        }
        if (i%2!=0){
            workMainTableTrObjList[i].style.backgroundColor="#FFFFFF"
        }
    }
    let allSelecetObj=document.getElementById("allSelecet");
    if (allSelecetObj){
        allSelecetObj.onclick=function (){
            let selectInputObjList=document.getElementsByClassName("selectInput");
            for (let i = 0; i < selectInputObjList.length; i++) {
                selectInputObjList[i].checked=true
            }
        }
    }

}